package com.mactivity.helper;

import java.security.MessageDigest;

import android.util.Log;

public class EncryptionHelper {

	public static synchronized String encrypt(String password) {
		StringBuffer encryptedPassword = new StringBuffer();
		try {
			// Create MD5 Hash
			MessageDigest digest = MessageDigest.getInstance("MD5");
			digest.update(password.getBytes());
			byte messageDigest[] = digest.digest();

			for (int i = 0; i < messageDigest.length; i++)
				encryptedPassword.append(Integer
						.toHexString(0xFF & messageDigest[i]));

		} catch (Exception e) {
			Log.e(Constants.LOGGER_ERROR_TAG,
					"Error occured while encrypting the password:"
							+ e.getMessage());
		}

		return encryptedPassword.toString();
	}

}
